ALTER VIEW [dbo].[View_FW_Company2Action]
AS
SELECT
        fc2a.Company2ActionGUID,
        fc2a.CompanyGUID,
        fc2a.ActionGUID,
        fc2a.TenantId,
        fc2a.IsDeleted,
        fc2a.CreateTime,
        fc2a.BuUnitGUID,
		fc.CompanyName,
		fa.ActionName,
		(SELECT TOP(1)  ApplicationGUID  FROM dbo.FW_Application2Module WHERE ModuleGUID=ff.ModuleGUID  ORDER BY CreateTime DESC) AS ApplicationGUID
FROM dbo.FW_Company2Action  fc2a
LEFT JOIN dbo.FW_Company fc ON fc.CompanyGUID=fc2a.CompanyGUID
LEFT JOIN dbo.FW_Action fa ON fa.ActionGUID=fc2a.ActionGUID
LEFT JOIN dbo.FW_Function ff ON ff.FunctionGUID=fa.FunctionGUID 

